// pages/recruitDynamics/newAdd/newAdd.js
import { throttle } from "../../../utils/throttle";
Page({
  /**
   * 页面的初始数据
   */
  data: {
    hidden: true, //是否隐藏滚动页面时的下拉栏
    timeType: "本月",
    city: "广州市",
    county: "天河区",
    unitList: [
      {
        unitName: "深圳市罗湖小学",
        place: "广州市天河区中海康城花园香雪兰二街2号",
        jobCount: 9,
        follow: 389,
      },
      {
        unitName: "第三小学附属幼儿园",
        place: "中国云南省昆明市昆明经济技术开发区呈贡区景明北路",
        jobCount: 9,
        follow: 389,
      },
      {
        unitName: "广州市增城区教育局",
        place: "中国云南省昆明市昆明经济技术开发区呈贡区景明北路",
        jobCount: 9,
        follow: 389,
      },
      {
        unitName: "第三小学附属幼儿园",
        place: "中国云南省昆明市昆明经济技术开发区呈贡区景明北路",
        jobCount: 9,
        follow: 389,
      },
      {
        unitName: "广州市增城区教育局",
        place: "中国云南省昆明市昆明经济技术开发区呈贡区景明北路",
        jobCount: 9,
        follow: 389,
      },
      {
        unitName: "第三小学附属幼儿园",
        place: "中国云南省昆明市昆明经济技术开发区呈贡区景明北路",
        jobCount: 9,
        follow: 389,
      },
      {
        unitName: "广州市增城区教育局",
        place: "中国云南省昆明市昆明经济技术开发区呈贡区景明北路",
        jobCount: 9,
        follow: 389,
      },
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {},
  /**
   * 页面渲染完成，获取标题底部定位
   */
  onReady() {
      const that = this;
      wx.createSelectorQuery()
        .select("#title")
        .boundingClientRect()
        .exec(function (res) {
          that.setData({
            titleBottom: res[0].bottom,
          });
        });
  },
  /**
   * 监听页面滚动
   */
  onPageScroll: throttle(function (data) {
    const { scrollTop } = data;
    const { titleBottom } = this.data;
    if (scrollTop > titleBottom) {
      wx.setNavigationBarTitle({ title: "新增学校单位" });
      this.setData({ hidden: false });
    } else {
      wx.setNavigationBarTitle({ title: "招教概况" });
      this.setData({ hidden: true });
    }
  }),
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},
});
